Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored main branch #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jun 22, 2023

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from xoiopure June 22, 2023 10:21
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

self.setText('property "{}:{}"'.format(node.name(), name))
self.setText(f'property "{node.name()}:{name}"')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PropertyChangedCmd.__init__ refactored with the following changes:

self.setText('lock port "{}"'.format(port.name()))
self.setText(f'lock port "{port.name()}"')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PortLockedCmd.__init__ refactored with the following changes:

self.setText('unlock port "{}"'.format(port.name()))
self.setText(f'unlock port "{port.name()}"')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PortUnlockedCmd.__init__ refactored with the following changes:

Comment on lines -394 to +396
self.setText('show port {}'.format(self.port.name()))
self.setText(f'show port {self.port.name()}')
else:
self.setText('hide port {}'.format(self.port.name()))
self.setText(f'hide port {self.port.name()}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PortVisibleCmd.__init__ refactored with the following changes:

_NodeClass = self.__nodes.get(node_type)
if _NodeClass:
if _NodeClass := self.__nodes.get(node_type):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeFactory.create_node_instance refactored with the following changes:

Comment on lines -1464 to +1476
for port in node.input_ports() + node.output_ports():
if port.locked():
locked_ports.append('{0.node.name}: {0.name}'.format(port))

locked_ports.extend(
'{0.node.name}: {0.name}'.format(port)
for port in node.input_ports() + node.output_ports()
if port.locked()
)
base_nodes.append(node)

if locked_ports:
message = (
'Selected nodes cannot be extracted because the following '
'ports are locked:\n{}'.format('\n'.join(sorted(locked_ports)))
)
if prompt_warning:
message = (
'Selected nodes cannot be extracted because the following '
'ports are locked:\n{}'.format('\n'.join(sorted(locked_ports)))
)
self._viewer.message_dialog(message, 'Can\'t Extract Nodes')
return

if push_undo:
self._undo_stack.beginMacro(
'extracted "{}" node(s)'.format(len(nodes))
)
self._undo_stack.beginMacro(f'extracted "{len(nodes)}" node(s)')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeGraph.extract_nodes refactored with the following changes:

Comment on lines -1510 to +1504
nodes = []
for item in self._viewer.selected_nodes():
node = self._model.nodes[item.id]
nodes.append(node)
return nodes
return [self._model.nodes[item.id] for item in self._viewer.selected_nodes()]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeGraph.selected_nodes refactored with the following changes:

Comment on lines -1589 to +1586
new_name = '{} {}'.format(name, x)
new_name = f'{name} {x}'
if new_name not in node_names:
return new_name

version = search.group(1)
version = search[1]
name = name[:len(version) * -1].strip()
for x in range(1, len(node_names) + 2):
new_name = '{} {}'.format(name, x)
new_name = f'{name} {x}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeGraph.get_unique_name refactored with the following changes:

Comment on lines -1658 to +1648
nodes_data.update(node_dict)
nodes_data |= node_dict
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeGraph._serialize refactored with the following changes:

Comment on lines -1728 to +1718
node = self._node_factory.create_node_instance(identifier)
if node:
if node := self._node_factory.create_node_instance(identifier):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeGraph._deserialize refactored with the following changes:

Comment on lines -1854 to +1843
raise IOError('file does not exist: {}'.format(file_path))
raise IOError(f'file does not exist: {file_path}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeGraph.load_session refactored with the following changes:

Comment on lines -1868 to +1864
raise IOError('file does not exist: {}'.format(file_path))
raise IOError(f'file does not exist: {file_path}')

try:
with open(file_path) as data_file:
layout_data = json.load(data_file)
except Exception as e:
layout_data = None
print('Cannot read data from file.\n{}'.format(e))
print(f'Cannot read data from file.\n{e}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeGraph.import_session refactored with the following changes:

Comment on lines -1902 to +1891
serial_str = json.dumps(serial_data)
if serial_str:
if serial_str := json.dumps(serial_data):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeGraph.copy_nodes refactored with the following changes:

Comment on lines -1965 to +1953
print('ERROR: Can\'t Decode Clipboard Data:\n'
'"{}"'.format(cb_text))
print(f"""ERROR: Can\'t Decode Clipboard Data:\n"{cb_text}\"""")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeGraph.paste_nodes refactored with the following changes:

Comment on lines -2024 to +2011
text = '{} ({}) nodes'.format(states[mode], len(nodes))
text = f'{states[mode]} ({len(nodes)}) nodes'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeGraph.disable_nodes refactored with the following changes:

Comment on lines -250 to +248
return '<{}("{}") object at {}>'.format(
self.__class__.__name__, self.name(), hex(id(self)))
return f'<{self.__class__.__name__}("{self.name()}") object at {hex(id(self))}>'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeGraphCommand.__repr__ refactored with the following changes:

return '<{}(\'{}\') object at {}>'.format(
self.__class__.__name__, self.name, hex(id(self)))
return f"<{self.__class__.__name__}(\'{self.name}\') object at {hex(id(self))}>"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PortModel.__repr__ refactored with the following changes:

Comment on lines -120 to +119
return '<{}(\'{}\') object at {}>'.format(
self.__class__.__name__, self.name, self.id)
return f"<{self.__class__.__name__}(\'{self.name}\') object at {self.id}>"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeModel.__repr__ refactored with the following changes:

raise NodePropertyError(
'"{}" reserved for default property.'.format(name))
raise NodePropertyError(f'"{name}" reserved for default property.')
if name in self._custom_prop.keys():
raise NodePropertyError(
'"{}" property already exists.'.format(name))
raise NodePropertyError(f'"{name}" property already exists.')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeModel.add_property refactored with the following changes:

Comment on lines -182 to +178
raise NodePropertyError('No property "{}"'.format(name))
raise NodePropertyError(f'No property "{name}"')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeModel.set_property refactored with the following changes:

Comment on lines -229 to +225
attrs = self._TEMP_property_attrs.get(name)
if attrs:
if attrs := self._TEMP_property_attrs.get(name):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeModel.get_tab_name refactored with the following changes:

Comment on lines -253 to +248
model = self._graph_model
if model:
if model := self._graph_model:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeModel.add_port_accept_connection_type refactored with the following changes:

Comment on lines -294 to +288
model = self._graph_model
if model:
if model := self._graph_model:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeModel.add_port_reject_connection_type refactored with the following changes:

Comment on lines -387 to +380
connected_ports = model.to_dict['connected_ports']
if connected_ports:
if connected_ports := model.to_dict['connected_ports']:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeModel.to_dict refactored with the following changes:

Comment on lines -540 to +530
connection_data[accept_ptype] = set([accept_pname])
connection_data[accept_ptype] = {accept_pname}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodeGraphModel.add_port_accept_connection_type refactored with the following changes:

Comment on lines -304 to +301
raise ValueError('label "{}" already in use for "{}"'
.format(label, labels[label]))
raise ValueError(f'label "{label}" already in use for "{labels[label]}"')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodesPaletteWidget.set_category_label refactored with the following changes:

return '<{} object at {}>'.format(
self.__class__.__name__, hex(id(self))
)
return f'<{self.__class__.__name__} object at {hex(id(self))}>'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodesTreeWidget.__repr__ refactored with the following changes:

Comment on lines -70 to +68
node_ids = ['node:{}'.format(i.toolTip(0)) for i in items]
node_ids = [f'node:{i.toolTip(0)}' for i in items]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodesTreeWidget.mimeData refactored with the following changes:

Comment on lines -94 to +92
label = '{}'.format(category)
label = f'{category}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NodesTreeWidget._build_tree refactored with the following changes:

self._button.setToolTip(
'rgb: {}\nhex: {}'.format(self._color[:3], hex_color)
)
self._button.setToolTip(f'rgb: {self._color[:3]}\nhex: {hex_color}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PropColorPickerRGB._update_color refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants